﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="paringliht_v4_evaadress", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(ParinglihtV4Evaadress))]
    public class ParinglihtV4EvaadressSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IParinglihtV4Evaadress clazz;
        
        public ParinglihtV4EvaadressSerializer(IParinglihtV4Evaadress clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("asukoht_ettevotja_aadressis");
            if (clazz.AsukohtEttevotjaAadressis!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsukohtEttevotjaAadressis))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("asukoha_ehak_kood");
            if (clazz.AsukohaEhakKood!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsukohaEhakKood))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("asukoha_ehak_tekstina");
            if (clazz.AsukohaEhakTekstina!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsukohaEhakTekstina))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("indeks_ettevotja_aadressis");
            if (clazz.IndeksEttevotjaAadressis!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.IndeksEttevotjaAadressis))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="asukoht_ettevotja_aadressis") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsukohtEttevotjaAadressis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asukoht_ettevotja_aadressis")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringliht_v4_evaadress>asukoht_ettevotja_aadressis", Reader.LocalName);
            }
            if (Reader.LocalName=="asukoha_ehak_kood") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsukohaEhakKood = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asukoha_ehak_kood")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringliht_v4_evaadress>asukoha_ehak_kood", Reader.LocalName);
            }
            if (Reader.LocalName=="asukoha_ehak_tekstina") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsukohaEhakTekstina = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("asukoha_ehak_tekstina")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringliht_v4_evaadress>asukoha_ehak_tekstina", Reader.LocalName);
            }
            if (Reader.LocalName=="indeks_ettevotja_aadressis") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.IndeksEttevotjaAadressis = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("indeks_ettevotja_aadressis")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>paringliht_v4_evaadress>indeks_ettevotja_aadressis", Reader.LocalName);
            }
        }
    }
}
